package com.dstats.datamodel;

import android.content.ContentValues;
import android.database.Cursor;

import com.dstats.data.AppDataContract;

import java.util.List;

public class Hero implements DataModel {
    public static List<Hero> heroes;
    private int id;
    private String name;
    private String localized_name;
    private Heropedia heropedia;
    private static final String npc_dota_hero = "npc_dota_hero_";
    public static final String url_imgs = "http://cdn.dota2.com/apps/dota2/images/heroes/";
    private static final String HeroPediaUrl = "http://www.dota2.com/hero/";
    private static final String endUrl = "_lg.png";

    public int getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    public String getLocalized_name() {
        return localized_name;
    }

    public Hero(Cursor cursor) {
        if(!cursor.isNull(cursor.getColumnIndex(AppDataContract.AppHeroEntry.NAME)))
            name = cursor.getString(cursor.getColumnIndex(AppDataContract.AppHeroEntry.NAME));

        if(!cursor.isNull(cursor.getColumnIndex(AppDataContract.AppHeroEntry.LOCALIZED_NAME)))
            localized_name = cursor.getString(cursor.getColumnIndex(AppDataContract.AppHeroEntry.LOCALIZED_NAME));

        if(!cursor.isNull(cursor.getColumnIndex(AppDataContract.AppHeroEntry._ID)))
            id = cursor.getInt(cursor.getColumnIndex(AppDataContract.AppHeroEntry._ID));
    }

    public String getImgResString() {
        return url_imgs + getShortName() + endUrl;
    }

    public String getShortName() {
        return name.replaceAll(npc_dota_hero, "");
    }

    @Override
    public ContentValues getContentValues() {
        ContentValues values = new ContentValues();
        values.put(AppDataContract.AppHeroEntry._ID, id);
        values.put(AppDataContract.AppHeroEntry.NAME, name);
        values.put(AppDataContract.AppHeroEntry.LOCALIZED_NAME, localized_name);
        return values;
    }

    public Heropedia getHeropedia() {
        return heropedia;
    }

    public void setHeropedia(Heropedia heropedia) {
        this.heropedia = heropedia;
    }


}

